/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** *****************************************************************************************************
 *  \file     lld_platform.h                                                                            *
 *  \brief    This file contains interface header for lld platform                                      *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date           <th>Version                                                                   *
 * <tr><td>2024/11/28     <td>1.0.0                                                                     *
 * </table>                                                                                             *
 *******************************************************************************************************/
#ifndef LLD_PLATFORM_H
#define LLD_PLATFORM_H

/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Std_Types.h"
#include "OsIf.h"
#include "RegHelper.h"
#include "Platform_Types.h"

/********************************************************************************************************
 *                                  Global Types definition                                             *
 *******************************************************************************************************/
/** \brief LLD error ID type */
typedef Std_ReturnType lld_status_t;
typedef sint32 lld_int_t;

/********************************************************************************************************
 *                                 Global Macro definition                                              *
 *******************************************************************************************************/
/** \brief Turn off interruptions */
#define LLD_ENTER_CRITIAL_AREA(x) SchM_Enter_EXCLUSIVE_AREA()
/** \brief Resumption of interruptions */
#define LLD_EXIT_CRITIAL_AREA(x) SchM_Exit_EXCLUSIVE_AREA()

/** \brief Invalid Cache */
#define LLD_INVALIDATE_CACHE(addr, size) Mcal_InvalidateCache(addr, size)
/** \brief Clear buffer to ram */
#define LLD_CLEAN_CACHE(addr, size) Mcal_CleanCache(addr, size)
/** \brief Clear buffer and invalid cache */
#define LLD_FLUSH_CACHE(addr, size) Mcal_FlushCache(addr, size)

/** \brief get core ID */
#define LLD_GET_COREID() Mcal_GetCpuIndex()

/** \brief get core ID */
#define LLD_UDELAY(us) Mcal_udelay(us)

/** \brief Definition of data types */
#define uint8_t uint8
#define uint16_t uint16
#define uint32_t uint32
#define uint64_t uint64
#define int8_t sint8
#define int16_t sint16
#define int32_t sint32
#define int64_t sint64
#define bool boolean
#define true TRUE
#define false FALSE
#ifdef  NULL
#undef  NULL
#define NULL NULL_PTR
#endif


/********************************************************************************************************
 *                                      Include mcal header files                                       *
 *******************************************************************************************************/
#include "Mcal_Delay.h"
#include "SchM_Base.h"
#include "Mcal_Cache.h"


#endif /* LLD_PLATFORM_H */
/* End of file */

